package com.hdw.web.base.system.controller;

import com.hdw.api.base.system.service.IHelloService;
import com.hdw.common.core.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: ltx
 * @Date: 2021/5/18 14:06
 * @Description:
 */
@Slf4j
@Api(value = "hello接口", tags = {"hello接口"})
@RestController
@RequestMapping("/sys/dic")
public class HelloController {
    @DubboReference
    private IHelloService helloService;

    @ApiOperation("说")
    @GetMapping("/say")
    public CommonResult<String> say(@RequestParam(required = false) @ApiParam(value = "字符串") String str) {
        RpcContext.getContext().setAttachment("index", "12377"); // 隐式传参，后面的远程调用都会隐式将这些参数发送到服务器端，类似cookie，用于框架集成，不建议常规业务使用
        return CommonResult.success(helloService.say(str));
    }

    @ApiOperation("吃")
    @GetMapping("/eat")
    public CommonResult<Map<String, Object>> eat(@RequestParam(required = false) @ApiParam(value = "字符串") String str) {
        RpcContext.getContext().setAttachment("index", "45688"); // 隐式传参，后面的远程调用都会隐式将这些参数发送到服务器端，类似cookie，用于框架集成，不建议常规业务使用
        return CommonResult.success(helloService.eat(str));
    }
}
